<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>设备台账</title>
    <link rel="stylesheet" href="/lib/layui/layui/css/layui.css?20190817.1">
    <link rel="stylesheet" href="/lib/layui/layui/css/common.css">
    <link rel="stylesheet" href="/lims/css/eleTree.css">
    <script src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/global.js"></script>
    <script type="text/javascript" src="../../js/jquery/jquery-1.9.1.js"></script>
    <script src="../../js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layui/layui/js/common.js?v=20190726" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layui/layui/js/baseCode/base.js?v=2019080918:09" type="text/javascript" charset="utf-8"></script>
    <style>
        .layui-card-header{
            border-bottom: 1px solid #eee;
        }
        .mbox{
            padding: 8px;
        }
        .inbox{
            padding: 5px;
            padding-right: 30px;
        }
        .deptinput{
            display: inline-block;
            width: 75%;
        }
        .layui-btn{
            margin-left: 10px;
        }
        .layui-btn .layui-icon{
            margin-right: 0px;
        }
        .red{
            color: red;
            font-size: 16px;
        }
        .layui-form-label{
            padding: 8px 15px;
        }
        .layui-card-body{
            display: flex;
        }
        .layui-lf{
            min-width: 16%;
            overflow-x: auto;
            height: 600px !important;
        }
        .layui-rt{
            width: 84%;
            margin-left: 6px;
            margin-top: -10px;
        }
        .treeTitle{
            display: flex;
            box-sizing: border-box;
            justify-content: center;
            align-items: center;
            width: 100%;
            height: 30px;
            background-color: #00a0e9;
            color: #fff;
            padding: 15px;
            position: relative;
        }
        .layui-nav-item,.layadmin-flexible{
            position: absolute;
            left: 5px;
            top: 23px;
            z-index: 9999999;
        }
        .rtfix{
            width:200px;
            overflow-x: scroll;
        }
        .bg{
            background-color: #F2F2F2;
        }
        .bgs{
            background-color: #F2F2F2;
        }
        .back{
            background-color: #ccc;
        }
        /*滚动条样式*/
        /*.rtfix::-webkit-scrollbar {!*滚动条整体样式*!*/
        /*width: 4px;     !*高宽分别对应横竖滚动条的尺寸*!*/
        /*height: 10px;*/
        /*}*/
        /*.rtfix::-webkit-scrollbar-button{*/
        /*background-color: #000;*/
        /*border:1px solid #ccc;*/
        /*display:block;*/
        /*}*/
        /*.rtfix::-webkit-scrollbar-thumb {!*滚动条里面小方块*!*/
        /*border-radius: 5px;*/
        /*-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);*/
        /*background: rgba(0,0,0,0.2);*/
        /*}*/
        /*.rtfix::-webkit-scrollbar-track {!*滚动条里面轨道*!*/
        /*-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);*/
        /*border-radius: 0;*/
        /*background: rgba(0,0,0,0.1);}*/
        .eleTree{
            cursor: pointer;
        }
        .layui-table-view .layui-table td, .layui-table-view .layui-table th{
            padding: 3px 0;
        }
        .layui-tab-title{
            height: 30px;
        }
        .layui-tab-title li{
            height: 36px;
            margin-top: -5px;
        }
        .layui-tab layui-tab-card{
            margin-top: -4px;
        }
        .layui-tab-card>.layui-tab-title .layui-this:after {
            border-width: 0px;
        }
        .baseinfo td{
            padding: 5px 2px;
        }
        .active{
            display: none;
        }
        .back{
            background-color: #F2F2F2;
        }
        .layui-colla-item {
            position: relative;
        }
        .layui-collapse .layui-card-body{
            padding: 0 8px;
        }
        .repairLable{
            padding: 8px 15px;
            text-align: right;
            vertical-align: middle;
        }
        .layui-form-select dl dd{
            height: 32px;
            line-height: 32px;
        }
        .layui-form-select .layui-select-title .layui-input{
            height: 32px;
        }
        #formTest .layui-form-select input,#lendListTest .layui-form-select input{
            height: 32px;
        }
        .layui-input{
            height: 32px !important;
        }
        .layui-form-item{
            margin-bottom: 5px; !important;
        }
        .layui-form-label{
            width: 70px; !important;
        }
    </style>
</head>
<body>
<div class="mbox">
    <div class="layui-card">
        <div class="layui-card-body" style="padding-left: 6px;">
            <div class="layui-lf rtfix">
                <div class="treeTitle" id="equip" dataType="0" >设备类别
                </div>
                <div class="panel-body">
                    <div class="eleTree ele1" lay-filter="data1"></div>
                </div>
            </div>
            <div class="layui-rt" style="position: relative">
                <div class="layui-nav-item layadmin-flexible" id="fixed" lay-unselect="">
                    <a href="javascript:;" layadmin-event="flexible" title="侧边伸缩">
                        <i class="layui-icon layui-icon-shrink-right" id="LAY_app_flexible"></i>
                    </a>
                </div>
                <table id="Settlement" lay-filter="SettlementFilter"></table>
                <div class="layui-tab layui-tab-card"lay-filter="demo" >
                    <ul class="layui-tab-title">
                        <li class="layui-this">基本信息</li>
                        <%--<li>设备能力</li>--%>
                        <li>维修记录</li>
                        <li>借用/归还记录</li>
                        <li>使用记录</li>
                        <li>定期事件</li>
                        <li>转移记录</li>
                        <li>设备配件</li>
                        <li>设备附件</li>
                    </ul>
                    <div class="layui-tab-content" style="padding: 2px">
                        <div class="layui-tab-item layui-show">
                            <table class="layui-table" lay-skin="line">
                                <colgroup>
                                    <col width="">
                                    <col width="">
                                    <col width="">
                                    <col>
                                </colgroup>
                                <thead>
                                <tr>
                                    <th colspan="4"style="padding: 6px 2px">设备信息</th>
                                </tr>
                                </thead>
                                <tbody class="baseinfo">
                                <tr>
                                    <td>资产编号：<sapn style="color: #111" id="equipNo" class="none"></sapn></td>
                                    <td>设备名称：<sapn style="color: #111" id="equipName"class="none"></sapn></td>
                                    <td>所属部门：<span style="color: #111" id="deptName"class="none"></span></td>
                                    <td>设备类型：<span style="color: #111" id="equipTypeName"class="none"></span></td>
                                </tr>
                                <tr>
                                    <td>设备状况：<span style="color: #111" id="equipStatuasId"class="none"></span></td>
                                    <td>型号：<span style="color: #111" id="modelNo"class="none"></span></td>
                                    <td>规格：<span style="color: #111" id="spec"class="none"></span></td>
                                    <td>负责人/保管人：<span style="color: #111" id="custodian" class="none"></span></td>
                                </tr>
                                <tr>
                                    <td>供应商：<span style="color: #111" id="supplier" class="none"></span></td>
                                    <td>生产厂家：<span style="color: #111" id="manufacturer" class="none"></span></td>
                                    <td>出厂编号：<span style="color: #111" id="factoryNo" class="none"></span></td>
                                    <td>出厂日期：<span style="color: #111" id="dateProduc" class="none"></span></td>
                                </tr>
                                <tr>

                                    <td>技术参数：<span style="color: #111" id="technicalParm" class="none"></span></td>
                                    <td>入账时间：<span style="color: #111"id="recordDate" class="none"></span></td>
                                    <td>资产原值：<span style="color: #111" id="assetsCost" class="none"></span></td>
                                    <td>资产来源：<span style="color: #111" id="sourceAssets" class="none"></span></td>
                                </tr>
                                <tr class="chooseTop">
                                    <td>产权归属：<span style="color: #111" id="propertyId" class="none"></span></td>
                                    <td>设备功率：<span style="color: #111" id="accountFile" class="none"></span></td>
                                    <td>设备序列号：<span style="color: #111" id="cloudSn" class="none"></span></td>
                                    <td>备注：<span style="color: #111" id="memo" class="none"></span></td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                        <div class="layui-tab-item"><%--设备维修记录--%>
                            <form class="layui-form" lay-filter="formTest" id="formTest" action=""style="width: 100%;margin: 0 auto;">
                                <div class="layui-form-item" style="display: inline-block;width: 25%;margin-top:10px;">
                                    <label class="layui-form-label repairLable">现象分类</label>
                                    <div class="layui-input-inline layui-form" style="width: 60%;">
                                        <select name="faultType" class="faultType layui-input layui-select" id="faultType">
                                            <option value="">请选择</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-form-item" style="display: inline-block;width: 25%;margin-top:10px;">
                                    <label class="layui-form-label repairLable">发生部位</label>
                                    <div class="layui-input-inline" style="width: 60%">
                                        <input type="text" id="faultPosition" maxlength="30" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item" style="display: inline-block;width: 25%;margin-top:10px;">
                                    <label class="layui-form-label repairLable">报修人</label>
                                    <div class="layui-input-inline" id="equipmentType" style="width: 60%">
                                        <input type="text" id="applicant" maxlength="30" class="layui-input">
                                    </div>
                                </div>
                                <br />
                                <div class="layui-form-item" style="display: inline-block;width:48%;">
                                    <div class="layui-inline">
                                        <label class="layui-form-label repairLable">报修时间</label>
                                        <div class="layui-input-inline" style="width: 34%">
                                            <input type="text" id="beginApplicationTime" style="height: 32px" autocomplete="off" class="layui-input">
                                        </div>
                                        <%--repairLable--%>
                                        <div class="layui-form-mid " style="">至</div>
                                        <div class="layui-input-inline" style="width: 34%">
                                            <input type="text" id="endApplicationTime" style="height: 32px" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>

                                </div>
                                <%--<div class="layui-form-item" style="display: inline-block;margin-top: 10px;width: 22%; ">--%>
                                    <%--<div class="layui-inline"></div>--%>

                                <%--</div>--%>
                                <div class="layui-form-item" style="display: inline-block;width: 30%;">
                                    <button type="button" style="margin-left:0px;" class="layui-btn repairSerch layui-btn-sm"><i class="layui-icon layui-icon-search"></i>搜索</button>
                                    <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
                                </div>
                            </form>
                            <table id="RepairTable" lay-filter="RepairTableFilter"></table>
                        </div>
                        <%--设备借还记录表--%>
                        <div class="layui-tab-item">
                            <form class="layui-form" lay-filter="lendListTest" id="lendListTest" action=""style="width: 100%;margin: 0 auto;">
                                <div class="layui-form-item" style="display: inline-block;margin-top: 10px;width: 25%;">
                                    <label class="layui-form-label repairLable">借用部门：</label>
                                    <div class="layui-input-inline layui-form" style="width: 60%">
                                        <select name="borrowerDetpId" id="deparment">
                                            <option value="" >请选择</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-form-item" style="display: inline-block;margin-top: 10px;width: 25%;">
                                    <label class="layui-form-label repairLable">归还状态：</label>
                                    <div class="layui-input-inline" style="width: 60%">
                                        <select name="returnStatus" class="faultType">
                                            <option value="">请选择</option>
                                            <option value="0">未归还</option>
                                            <option value="1">已归还</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-form-item" style="display: inline-block;margin-top: 10px;width: 25%;">
                                    <label class="layui-form-label repairLable">审批状态：</label>
                                    <div class="layui-input-inline"  style="width: 60%">
                                        <select name="approverStatus" class="faultType">
                                            <option value="">请选择</option>
                                            <option value="0">新建</option>
                                            <option value="1">待批</option>
                                            <option value="2">已准</option>
                                            <option value="3">未准</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-form-item" style="display: inline-block;margin-top: 10px;width: 25%;">
                                    <label class="layui-form-label repairLable">借用人：</label>
                                    <div class="layui-input-inline"  style="width: 60%">
                                        <input type="text" name="borrowerUser"  maxlength="30" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item" style="display: inline-block;width:48%;">
                                    <div class="layui-inline">
                                        <label class="layui-form-label repairLable">借用日期：</label>
                                        <div class="layui-input-inline" style="width: 34%">
                                            <input type="text" id="borrowTime" name="borrowTime" autocomplete="off" class="layui-input">
                                        </div>
                                        <div class="layui-form-mid" style="">至</div>
                                        <div class="layui-input-inline" style="width: 34%">
                                            <input type="text" id="returnTime" name="returnTime"  autocomplete="off" class="layui-input">
                                        </div>
                                    </div>

                                </div>
                                <%--<div style="display: inline-block;margin-top: 10px;width: 24%;">--%>

                                <%--</div>--%>
                                <div class="layui-from-item" style="display: inline-block;margin-left: -3%;">
                                    <button type="button" class="layui-btn layui-btn-sm" lay-submit lay-filter="lendList-submit"><i class="layui-icon layui-icon-search"></i>搜索</button>
                                    <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
                                </div>
                            </form>
                            <table class="layui-table" id="lendListTable"  lay-filter="lendListTableFilter" ></table>
                        </div>
                        <%--设备使用记录--%>
                        <div class="layui-tab-item">
                            <form class="layui-form" lay-filter="useLogTest" action=""style="width: 100%;margin: 0 auto;">
                                <div class="layui-form-item" style="display: inline-block;margin-top: 10px;width: 25%;">
                                    <label class="layui-form-label repairLable">使用人：</label>
                                    <div class="layui-input-inline"  style="width: 60%">
                                        <input type="text" name="borrowerUser"  maxlength="30" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item" style="display: inline-block;margin-top: 10px;width: 25%;">
                                    <label class="layui-form-label repairLable">立项编号：</label>
                                    <div class="layui-input-inline"  style="width: 60%">
                                        <input type="text" name="projectNo"  maxlength="30" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item" style="display: inline-block;margin-top: 10px;width: 25%;">
                                    <label class="layui-form-label repairLable">项目名称：</label>
                                    <div class="layui-input-inline"  style="width: 60%">
                                        <input type="text" name="projectName"  maxlength="30" class="layui-input">
                                    </div>
                                </div>
                                <br />
                                <div class="layui-form-item" style="display: inline-block;width:25%; margin-bottom:0px;">
                                        <label class="layui-form-label repairLable">开始使用时间：</label>
                                        <div class="layui-input-inline" style="width: 60%">
                                            <input type="text" id="logborrowTime" name="borrowTime" autocomplete="off" class="layui-input">
                                        </div>
                                </div>
                                <div class="layui-form-item" style="display: inline-block;width: 25%; margin-bottom:0px;">
                                    <label class="layui-form-label repairLable">结束使用时间：</label>
                                    <div class="layui-input-inline" style="width: 60%">
                                        <input type="text" id="logreturnTime"  name="returnTime" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item" style="display: inline-block;position: absolute;margin-left:5px;">
                                    <button type="button" class="layui-btn layui-btn-sm" lay-submit lay-filter="useLog-submit"><i class="layui-icon layui-icon-search"></i>搜索</button>
                                    <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
                                </div>
                            </form>
                            <table class="layui-table" id="useLogTable"  lay-filter="useLogTableFilter" ></table>
                        </div>
                        <%--定期事件记录--%>
                        <div class="layui-tab-item">
                            <form class="layui-form" lay-filter="eventSearch" action="" style="width: 100%;margin: 0 auto;">
                                <div style="display: inline-block;margin-top: 10px;width: 25%;">
                                    <label class="layui-form-label repairLable">事件类型：</label>
                                    <div class="layui-input-inline layui-form" style="width: 50%">
                                        <select name="equipEventType" class="equipEventType" id="equipEventType">
                                            <option value="">请选择</option>
                                            <option value="EQUIP_EVENT_TYPE1">检定校准</option>
                                            <option value="EQUIP_EVENT_TYPE2">期间核查</option>
                                        </select>
                                    </div>
                                </div>
                                <div style="display: inline-block;margin-top: 10px;">
                                    <label  class="layui-form-label search_field">查询字段</label>
                                    <div class="layui-input-inline"  >
                                        <select class="layui-select indexSeleOne"  lay-filter="columnName" name="columnName" id="columnName" autocomplete="off">
                                            <option value="">请选择</option>
                                            <option value="EQUIP_NAME">设备名称</option>
                                            <option value="FREQUENCY">维护频率</option>
                                            <option value="EXE_TIME">上次执行日期</option>
                                            <option value="EXPIRE_DATE">下次到期日期</option>
                                        </select>
                                    </div>
                                    <div class="layui-inline">
                                        <input class="layui-input" name="inputValue" id="inputValue1" autocomplete="off" style="height: 32px">
                                        <input class="layui-input" name="inputValue" id="inputValue" autocomplete="off" style="height: 32px;display: none">
                                    </div>
                                </div>
                                <div style="display: inline-block">
                                    <button type="button" class="layui-btn layui-btn-sm" lay-submit lay-filter="event-submit"><i class="layui-icon layui-icon-search"></i>搜索</button>
                                    <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
                                </div>
                            </form>
                            <table class="layui-table" id="eventTable"  lay-filter="eventTableFilter" ></table>
                        </div>
                        <%--设备转移记录--%>
                        <div class="layui-tab-item">
                            <form class="layui-form" lay-filter="lendListTest" action=""style="width: 100%;margin: 0 auto;">
                                <div id="serch" style="display: none">
                                    <div style="display: inline-block;margin-top: 10px;width: 24%;">
                                        <label class="layui-form-label repairLable">调拨日期：</label>
                                        <div class="layui-input-inline layui-form" style="width: 60%">
                                            <input type="text" id="transferDate" name="transferDate" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div style="display: inline-block;margin-top: 10px;width: 24%;">
                                        <label class="layui-form-label repairLable">原部门：</label>
                                        <div class="layui-input-inline layui-form" style="width: 60%">
                                            <select name="originalDeptId" id="oldeparment">
                                                <option value="" >请选择</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div style="display: inline-block;margin-top: 10px;width: 24%;">
                                        <label class="layui-form-label repairLable">新部门：</label>
                                        <div class="layui-input-inline layui-form" style="width: 60%">
                                            <select name="newDeptId" id="newdeparment">
                                                <option value="" >请选择</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div style="display: inline-block;margin-top: 10px;width: 24%;">
                                        <label class="layui-form-label repairLable">接收状态：</label>
                                        <div class="layui-input-inline" style="width: 60%">
                                            <select name="receiveStatus" class="faultType">
                                                <option value="">请选择</option>
                                                <option value="1">已接收</option>
                                                <option value="0">未接收</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div style="display: inline-block;margin-top: 10px;width: 24%;">
                                        <label class="layui-form-label repairLable">审批状态：</label>
                                        <div class="layui-input-inline"  style="width: 60%">
                                            <select name="approverStatus" class="faultType">
                                                <option value="">请选择</option>
                                                <option value="0">新建</option>
                                                <option value="1">待批</option>
                                                <option value="2">已准</option>
                                                <option value="3">未准</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div style="display: inline-block;margin-top: 10px;width: 24%;">
                                        <label class="layui-form-label repairLable">流水号：</label>
                                        <div class="layui-input-inline"  style="width: 60%">
                                            <input type="text" name="workflowNo"  maxlength="30" class="layui-input">
                                        </div>
                                    </div>
                                    <div style="display: inline-block;margin-left: -3%; margin-left: 15px;">
                                        <button type="button" class="layui-btn layui-btn-sm" lay-submit lay-filter="transList-submit"><i class="layui-icon layui-icon-search"></i>搜索</button>
                                        <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
                                    </div>
                                </div>
                            </form>
                            <table class="layui-table" id="transferTable"  lay-filter="transferTableFilter" ></table>
                        </div>
                        <%--设备配件--%>
                        <div class="layui-tab-item">
                            <table class="layui-table" id="equipAccessories"  lay-filter="equipAccessoriesFilter" ></table>
                        </div>
                        <%--设备附件--%>
                        <div class="layui-tab-item">
                            <table class="layui-table" id="equipEnclosure"  lay-filter="equipEnclosureFilter" ></table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="toolbar">
    <div class="demoTable" id="equipSear" style="float: right; margin-right:9px;margin-top: -1px;">
        <label style="float: left; margin-right:5px;">查询字段</label>
        <div class="layui-input-inline" style="float:left;">
            <select name="models" lay-verify="required" lay-filter="serachInfo" name="serachInfo" id="serachInfo1"  lay-search="" style="height: 10px">
                <option value="0">请选择查询字段</option>
                <option value="EQUIP_NO">资产编号</option>
                <option value="EQUIP_NAME">设备名称</option>
                <option value="EQUIP_STATUAS_CODE">设备状况</option>
                <option value="MODEL_NO">型号</option>
                <option value="SPEC">规格</option>
                <option value="MANUFACTURER">所属实验室</option>
                <option value="SUPPLIER">供应商</option>
                <option value="PROPERTY_CODE">产权归属</option>
                <option value="FACTORY_NO">出厂编号</option>
                <option value="CLOUD_SN">云端SN</option>
                <option value="DEPT_NAME">试验实</option>
            </select>
        </div>
        <div class="layui-inline">
            <input class="layui-input"  name="serchtexts" id="demoReloads" autocomplete="off" style="height: 32px;margin-left:5px;">
        </div>
        <button class="layui-btn" data-type="reload"  lay-event="modelSerch" style="height:30px;line-height: 30px">搜索</button>
    </div>
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="add" style="width: 70px" id="addEq">新建</button>
        <button class="layui-btn layui-btn-sm" lay-event="pedit" style="width: 70px" >批量修改</button>
        <button class="layui-btn layui-btn-sm" lay-event="pdel" style="width: 70px" onclick="doRemoveBatch()">批量删除</button>
        <button class="layui-btn layui-btn-sm" lay-event="import" style="width: 70px">导入</button>
        <button class="layui-btn layui-btn-sm" lay-event="search" style="width: 100px">查询所有设备</button>
    </div>
</script>
<script type="text/html" id="toolbars">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="add" style="width: 70px" href="/equipCert/addvice">新增</button>
        <button class="layui-btn layui-btn-sm" lay-event="pedit" style="width: 70px">批量修改</button>
    </div>
</script>
<script type="text/html" id="barOperation">
    <a class="layui-btn layui-btn-xs" lay-event="edit" id="edit1">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" >删除</a>
</script>
<script type="text/html" id="barOperation1">
    <a  data-type="1" class="layui-btn layui-btn-xs" lay-event="edit" >编辑</a>
</script>
<script type="text/html" id="repairToolbar">
    <a class="layui-btn layui-btn-sm" lay-event="repairDetail">详情</a>
</script>
<script type="text/html" id="approval">
    <div class="demoTable" id="transSe" style="float: left; margin-right:9px;margin-top: -1px;">
        <label style="float: left;width: 60px">查询字段</label>
        <div class="layui-input-inline" style="float:left; height: 20px;">
            <select  lay-verify="required" lay-filter="serachInfo" name="serachInfo" id="serachInfo" class="serachSelect" lay-search="" style="height: 32px;line-height: 32px">
                <option value="" style="height: 32px;">请选择查询字段</option>
                <option value="ORIGINAL_DEPT_ID">原部门</option>
                <option value="NEW_DEPT_ID">新部门</option>
                <option value="TRANSFER_DATE">调拨日期</option>
                <option value="APPLICATION">申请人</option>
                <option value="APPLICATION_TIME">申请时间</option>
                <option value="APPROVAL_STATUS">审批状态</option>
                <option value="list.RECEIVE_STATUS">接收状态</option>
            </select>
        </div>
        <div class="layui-inline">
<%--
            <input class="layui-input" name="searchtext" id="demoReloadss" autocomplete="off" style="height: 32px;">
--%>
            <input class="layui-input" name="searchtext1" id="searchtext1" autocomplete="off" style="height: 32px">
            <input class="layui-input" name="searchtext" id="searchtext" autocomplete="off" style="height: 32px;display: none">
        </div>
        <button type="button" class="layui-btn layui-btn-sm" lay-event="searchCust"><i class="layui-icon layui-icon-search"></i>搜索</button>
        <button class="layui-btn" data-type="reload"  lay-event="divSearch" style="height:30px;line-height: 30px;">高级搜索</button>
    </div>
    </div>
</script>
<%--wss  设备附件右侧操作栏--%>
<script type="text/html" id="equipoperation">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="deatil">查看</a>
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="del">删除</a>
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="down">下载</a>
</script>
<%--wss  设备附件头部按钮--%>
<script type="text/html" id="equipFileHeadBtn">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="add" style="width: 70px" >上传附件</button>
        <button class="layui-btn layui-btn-sm" lay-event="del" style="width: 70px">删除附件</button>
    </div>
</script>
<%--wss  设备配件头部按钮--%>
<script type="text/html" id="equipAccessHeadBtn">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="add" style="width: 70px" data-type="0" >新增</button>
        <button class="layui-btn layui-btn-sm" lay-event="edit" style="width: 70px">编辑</button>
        <button class="layui-btn layui-btn-sm" lay-event="del" style="width: 70px">删除</button>
    </div>
</script>
<%----------------------------------------------------数据操作--------------------------------------------------------------------------%>
<script type="text/javascript">
    var el
        ,aldata
        ,newstr='<div class="iptbox mnodec" pid="">'+
        '<input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="序号" class="layui-input pnul">'+
        '<input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="名称" class="layui-input shorts">'+
        '<input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="备注" class="layui-input longs">'+
        '<div class="btnls">'+
        '<button type="button" class="layui-btn layui-btn-primary layui-btn-sm limsAdd"><i class="layui-icon"></i></button>'+
        '<button type="button" class="layui-btn layui-btn-primary layui-btn-sm limsDel"><i class="layui-icon"></i></button>'+
        '</div>'+
        '</div>';
    var resultTypeData='';
    var a ="";
    var name;
    var pid;
    var directjudge;
    var idkey;
    $('.rtfix').css('max-height',autodivheight()-55)
    var tableObj;
    var RepairTableObject;//设备维修记录页签table实例对象
    var RepairequipId;//设备维修需要根据设备id查，这里记录到全局变量中
    var repalogId;//设备维修记录Id
    var resultTypeDatas;
    var resultTypeDatass;
    var alltable = []
    var rowData;
    var tabIndex=0;  //底部页签下标 wss
    var AllEquipTypeId;
    var dateKj;
    var model = "equipment";
    layui.use(['table','layer','form','element','eleTree','laydate','upload'], function(){
        var table = layui.table;
        var layer = layui.layer;
        var form = layui.form;
        var eleTree = layui.eleTree;
        var element = layui.element;
        var $ = layui.jquery;
        var laydate = layui.laydate;
        dateKj=laydate;
        var upload = layui.upload;
        laydate.render({
            elem: '#borrowTime'
            , trigger: 'click'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#returnTime'
            , trigger: 'click'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#transferDate'
            , trigger: 'click'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#logborrowTime'
            , trigger: 'click'
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#logreturnTime'
            , trigger: 'click'
            , format: 'yyyy-MM-dd'
        });
        $.ajax({
            type: 'get',
            url: '/EquipBorrow/getorganization',
            dataType: 'json',
            success: function (data) {
                var render = [];
                var t = data.data;
                render.push("<option class=''></option>");
                for (var i = 0; i < t.length; i++) {
                    render.push("<option class='' value=\"" + t[i].deptId + "\">" + t[i].deptName + "</option>");
                }
                $("#deparment").html(render.join(""));
                $("#oldeparment").html(render.join(""))
                form.render();
            }
        })
        //原部门所属组织下拉框
        $.ajax({
            type: 'get',
            url: '/equipTransfer/userDept',
            dataType: 'json',
            success: function (data) {
                var render = [];
                var deptdata=data.data
                render.push("<option class=''></option>");
                for (var i = 0; i < deptdata.length; i++) {
                    render.push("<option class='' value=\"" + deptdata[i].deptId + "\">" + deptdata[i].deptName + "</option>");
                }
                $("#newdeparment").html(render.join(""));
                form.render();
            }
        });
        var url='/equipment/deleteEquipment';
        //底部页签切换
        element.on('tab(demo)', function(data){
            var index=tabIndex=data.index;
            var tabledata=table.cache["Settlement"];
                tabRender(tabIndex,rowData);



            // var data="";
            //
            // switch(index){
            //     case 1:
            //             code(data.equipId);
            //         break;
            //     case 2://设备维修记录页签
            //         if(RepairTableObject==undefined){
            //             repairFunction(data.equipId);//初始化维修记录表格
            //         }else{
            //             var param = {
            //                 equipId:RepairequipId
            //             }
            //             RepairLoad(param);//重载维修记录表格
            //         }
            //         laydate.render({
            //             elem: '#beginApplicationTime'
            //             , trigger: 'click'//呼出事件改成click
            //             , format: 'yyyy-MM-dd'
            //         });
            //         laydate.render({
            //             elem: '#endApplicationTime'
            //             , trigger: 'click'//呼出事件改成click
            //             , format: 'yyyy-MM-dd'
            //         });
            //         break;
            //     case 3:    //设备借还记录
            //         var param={
            //             "equipId":data.equipId
            //         }
            //         equipBorrowReload(param)
            //         break
            //     case  4:    //设备使用记录
            //         var param={
            //             "equipId":data.equipId
            //         }
            //         equipuseLogReload(param)
            //         break;
            //     case  6:
            //         var param={
            //             "equipId":data.equipId
            //         }
            //         equiTransferReload(param)
            //         break;
            //     case  5:
            //         var param={
            //             "equipId":data.equipId
            //         }
            //         showEventTable(param)
            //         break;
            //         var param={
            //             "equipId":rowData.equipId
            //         }
            //         equipAccess(param);
            //         break;
            //     case 8:
            //         var param={
            //             "equipId":rowData.equipId
            //         }
            //         equipAFile(param);
            //         break;
            // }
        });
        // 初始化渲染 树形菜单
        el = eleTree.render({
            elem: '.ele1',
            showLine:true,
            url:'/equipmentType/showParentEquipmentType',
            lazy: true,
            load: function(data,callback) {
                $.post('/equipmentType/showChildEquipmentType?equipTypeId='+data.id,function (res) {
                    callback(res.data);//点击节点回调
                })
            },
            done:function (data) { //渲染完成回调
                aldata = data.data
                name=data.data[0].name //传的是默认选中的值
                pid = data.data[0].equipTypePid;
                directjudge=data.data[0].id;
                console.log(directjudge)
                AllEquipTypeId=data.data[0].id
                var parm ={
                    equipTypeId:AllEquipTypeId
                }
                getTabke(parm);
                var dataid=$('.ele1 div').attr("data-id")
                $('.eleTree-node').removeClass('back')
                $('.ele1 div[data-id='+dataid+']').addClass('back')
                $('.eleTree-node-group').css('background','#fff')
            }
        });
        // 节点点击事件
        eleTree.on("nodeClick(data1)",function(d) {
            // $("div[lay-id='Settlement'] .layui-table-body").find("tr[data-index=0]").click();
            var dataid=$('.ele1 div').attr("data-id")
            var a = d.data.currentData.id;
            $('.eleTree-node').removeClass('back')
            $(d.node[0]).addClass('back')
            $('.eleTree-node-group').css('background','#fff')
            var obj = d.data.currentData
            name = obj.name
            console.log(obj)
            pid = obj.equipTypePid;
            idkey = obj.id;
            AllEquipTypeId=obj.id;
            $.post('/equipmentType/showEquipmentTypeById?equipTypeId=' + obj.id, function (res) {
                var obj = res.data
                    , str;
            })
            var currentPage = 1
            // table.reload('Settlement',{
            //     url : '/equipment/selectAllEquipment',
            //     where:{"equipTypeId":AllEquipTypeId},
            //     data:{page:currentPage},
            //     page:{
            //         curr:currentPage
            //     },
            //     done:function(res){
            //         // var tabledata=table.cache["Settlement"];
            //         // if(tabledata!=undefined){
            //         //     rowData=tabledata[0]
            //         // }
            //        // display(res.data[0]);
            //         if(res.data.length!=undefined&&res.data.length>0){
            //             rowData=res.data[0]
            //             tabRender(tabIndex,rowData)   //wss
            //         }
            //     }
            // })
            var parm ={
                equipTypeId:AllEquipTypeId
            }

            rowData=undefined
            getTabke(parm);
            $(".layui-tab-card").children().find('li').eq(0).click();
        });
        table.on('toolbar(SettlementFilter)', function(obj){
            switch(obj.event){
                case 'add':
                    if(pid ==0){
                        layer.msg("一级类别下无法添加");
                        return false;
                    }else{
                        editAdd(0, idkey);
                        display(obj);
                    }
                    break;
                case 'search':
                    var currentPage = 1
                    table.reload('Settlement',{
                        url : '/equipment/selectAllEquipment',
                        data:{page:currentPage},
                        where:{equipTypeId:null},
                        page:{
                            curr:currentPage
                        }
                    })
                    break;
                case 'modelSerch':
                    var inptext=$(".demoTable input[name='serchtexts']").val();
                    var seletext=$("#equipSear").find("dl dd.layui-this").attr("lay-value");
                    if((inptext == "")&&(seletext==undefined)){
                        layer.msg("请输入需要搜索的条件");
                        return false;
                    }else if((inptext=="")&&(seletext!=undefined)){
                        layer.msg("请输入需要查询的条件");
                        return false;
                    }else if((inptext!="")&&(seletext==undefined)){
                        layer.msg("请选择查询的字段");
                        return false;
                    }else{
                        var datas={
                            equipTypeId:idkey,
                            inptext:inptext,
                            column:seletext
                        }
                        var stat=1
                        getTabke(datas,stat);
                    }
                    break;
            };
        });
        // 编辑/删除操作
        table.on('tool(SettlementFilter)', function(obj){//注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象
            var equipId= data.equipId;
            var urlTitle='/equipment';
            if(layEvent === 'del'){ //删除
                publicDelete(urlTitle+"/deleteEquipment",equipId+"",tableObj,table);
                //向服务端发送删除指令
            } else if(layEvent === 'edit'){ //编辑
                editAdd(1,equipId);}
            // }else if(layEvent === 'click'){
            //     display(data.equipId)
            // }
        });
        // //监听复选框事件
        table.on('checkbox(SettlementFilter)', function(obj){
            var tr = obj.tr[0];
            if(obj.checked){
                $(tr).addClass('bgs')
            }else{
                $(tr).removeClass('bgs').removeClass('bg')
            }
        });
        //监听表格行事件
        table.on('row(SettlementFilter)', function(obj){
            //repairFunction(RepairequipId);
            var data=obj.data;
            rowData=data;
            tabRender(tabIndex,rowData)
            var i=0;
            if(directjudge==pid||name=="传感器"){
                $('.hide').show();
                if( $('.hide').attr('dataType')==1){
                    $('.chooseBot').find('td').eq(0).before($('.chooseTop').find('td').eq(5))
                    $('.chooseBot').find('td').eq(0).before($('.chooseTop').find('td').eq(4));
                    $('.hide').attr('dataType',0)
                    if(obj.data.directionId=='三向'){
                        $('.hideY').css('visibility','visible')
                    }else{
                        $('.hideY').css('visibility','hidden')
                    }
                }else{
                    if(obj.data.directionId=='三向'){
                        $('.hideY').css('visibility','visible')
                    }else{
                        $('.hideY').css('visibility','hidden')
                    }
                }
            }else{
                $('.hide').hide();
                if($('.hide').attr('dataType')!=1) {
                    $('.chooseTop').find('td').eq(3).after($('.chooseBot').find('td').eq(0))
                    $('.chooseTop').find('td').eq(4).after($('.chooseBot').find('td').eq(1))
                    $('.hide').attr('dataType', 1)
                }
            }
            if(obj.data.dateProduc == undefined){
                obj.data.dateProduc = nowformat();
            } else{
                obj.data.dateProduc = format(obj.data.dateProduc);
            };
            if(obj.data.recordDate == undefined){
                obj.data.recordDate = nowformat();
            } else{
                obj.data.recordDate = format(obj.data.recordDate);
            };
            //选中行变颜色方法
            var index=$(this).attr('data-index');
            var tr=$(this).parent().children(tr);
            $(this).addClass("bg");
            for(var i=0;i<tr.length;i++){
                if(index != i) {
                    tr.eq(i).removeClass("bg");
                }
            }
            // 基本信息监听行事件
            $('#equipNo').html(undefind_nullStr(data.equipNo));
            $('#equipTypeName').html(undefind_nullStr(data.equipTypeName));
            $('#equipName').html(undefind_nullStr(data.equipName));
            $('#equipStatuasId').html(undefind_nullStr(data.equipStatuasId));
            $('#equipTypeId').html(undefind_nullStr(data.equipTypeId));
            $('#modelNo').html(undefind_nullStr(data.modelNo));
            $('#spec').html(undefind_nullStr(data.spec));
            $('#manufacturer').html(undefind_nullStr(data.manufacturer));
            $('#supplier').html(undefind_nullStr(data.supplier));
            $('#positionName').html(undefind_nullStr(data.positionName));
            $('#factoryNo').html(undefind_nullStr(data.factoryNo));
            $('#propertyNo').html(undefind_nullStr(data.propertyNo));
            $('#dateProduc').html(undefind_nullStr(format(data.dateProduc)));
            $('#recordDate').html(undefind_nullStr(format(data.recordDate)));
            $('#sourceAssets').html(undefind_nullStr(data.sourceAssets));
            $('#assetsCost').html(undefind_nullStr(data.assetsCost));
            $('#propertyId').html(undefind_nullStr(data.propertyId));
            $('#accountFile').html(undefind_nullStr(data.accountFile));
            $('#sensitivityX').html(undefind_nullStr(data.sensitivityX));
            $('#sensitivityY').html(undefind_nullStr(data.sensitivityY));
            $('#sensitivityZ').html(undefind_nullStr(data.sensitivityZ));
            $('#phyQuantiId').html(undefind_nullStr(data.phyQuantiId));
            $('#directionId').html(undefind_nullStr(data.directionId));
            $('#couplingId').html(undefind_nullStr(data.couplingId));
            $('#cloudSn').html(undefind_nullStr(data.cloudSn));
            $('#custodian').html(undefind_nullStr(data.custodian));
            $('#standMateYn').html(undefind_nullStr(data.standMateYn));
            $('#technicalParm').html(undefind_nullStr(data.technicalParm));
            $('#memo').html(undefind_nullStr(data.memo));
            $('#deptId').html(undefind_nullStr(data.deptId));
            $('#deptName').html(undefind_nullStr(data.deptName));
        });
        //设备台账设备能力同步能力项点击事件
        $(document).on('click','#syncbtn',function(){
            if(rowData ==undefined){

            }else{
                var syncId = rowData.equipId;
                $.ajax({
                    type: "post",
                    url: "/equipment/togetherEquipCapy",
                    dataType: "json",
                    data: {
                        equipId:syncId
                    },
                    success: function (res) {
                        if(res.code == 0){
                            layer.msg(res.msg);
                            code(syncId)
                        }else{
                            layer.msg(res.msg);
                        }
                    }
                })
            }

        });
        //设备台账设备能力保存点击事件
        $("#savebtn").click(function () {
            if(rowData==undefined){

            }else{
                var restr = JSON.stringify(resultTypeData);
                $.ajax({
                    type: "post",
                    url: "/equipment/editEquipCapyValue",
                    dataType: "json",
                    data: {
                        equipCapyValueJson:restr
                    },
                    success: function (res) {
                        if(res.code == 0){
                            layer.msg(res.msg);
                            code(rowData.equipId);
                        }else{
                            layer.msg(res.msg);
                        }
                    }
                })
            }

        })
        //点击表格 让其可编辑 并提示需要编辑的哪一项
        $(function(){
            $(".total").on("click",".edit",function(e){
                if (e.target == e.currentTarget) {
                    var typename = $(this).attr('typename');
                    var idx = $(this).attr('idx');
                    $(this).html('<input style="width:80%;height: 20px;padding: 5px 10px;" value="'+$(this).text()+'" />');
                    //提示框
                    var tips;
                    var that = this;
                    if (typename == "capyInitialValue") {
                        tips = layer.tips("<span style='color:#fff;'>请修改出产能力值</span>",that, {
                            tips: [2, '#393D49'],
                            time: 0,
                            area: 'auto',
                            maxWidth: 500
                        });
                    } else if (typename == "calibrationValue") {
                        tips = layer.tips("<span style='color:#fff;'>请修改检测能力值</span>",that, {
                            tips: [2, '#393D49'],
                            time: 0,
                            area: 'auto',
                            maxWidth: 500
                        });
                    }
                    $(this).find("input").focus();
                    $(this).find("input").blur(function(){
                        if($(this).val()==""){
                            $(this).remove();
                        }else{
                            $(this).closest("td").text($(this).val());
                        }
                        layer.close(tips);
                        resultTypeData[idx][typename] = $(this).val();
                    })
                }
            })
        })
        //维修记录搜索按钮点击事件
        $('.repairSerch').click(function(){
            var falutype = $("#faultType").val()//现象分类
            var faultPosition = $("#faultPosition").val()//发生部位
            var applicant=$("#applicant").val()//报修人
            var beginTime = $('#beginApplicationTime').val()//开始时间
            var endTime =  $('#endApplicationTime').val()//结束时间
            var  param = {}
            if(falutype==''&&faultPosition==''&&applicant==''&&beginTime==''&&endTime==''){
                param.equipId=RepairequipId;
                param.faultType='';
                param.faultPosition='';
                param.applicant='';
                param.beginTime='';
                param.endTime='';
                RepairLoad(param);//重载维修记录表格
            }else{
                param.faultType=falutype
                param.faultPosition=faultPosition
                param.applicant=applicant
                param.beginTime=beginTime
                param.endTime=endTime
                param.equipId=RepairequipId
                RepairLoad(param);//重载维修记录表格
            }
        })
        //监听维修表格行工具事件
        table.on('tool(RepairTableFilter)', function(obj){
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event;
            repalogId= data.repalogId;
            if(layEvent === 'repairDetail'){ //设备维修详情
                layer.open({
                    type: 2 //此处以iframe举例
                    , title: '维修记录'
                    , area: ['100%', '100%']
                    //, maxmin: true
                    , content: '/equipment/verifquip?weixyzbtn=detail'
                    , btn: ['确定']
                    , yes: function (index, layero) {
                        layer.closeAll()
                    }
                });
            }
        });
        //设备借还记录多条件搜索
        form.on('submit(lendList-submit)', function (data) {
            var datas = data.field;
            datas.equipId=rowData.equipId
            if(datas.borrowTime==''){
                delete datas.borrowTime
            }
            if(datas.returnTime==''){
                delete datas.returnTime
            }
            equipBorrowReload(datas)
        });
        //设备转移记录多条件搜索
        form.on('submit(transList-submit)', function (data) {
            var datas = data.field;
            datas.equipId=rowData.equipId
            if(datas.transferDate==''){
                delete datas.transferDate
            }
            equiTransferReload(datas)
        });
        //设备使用记录多条件查询
        form.on('submit(useLog-submit)', function (data) {
            var datas = data.field;
            datas.equipId=rowData.equipId
            if(datas.borrowTime==''){
                delete datas.borrowTime
            }
            if(datas.returnTime==''){
                delete datas.returnTime
            }
            equipuseLogReload(datas)
        });

        //转移记录操作栏事件
        table.on('toolbar(transferTableFilter)',function(index){
            var event=index.event;
            switch (event){
                case 'divSearch':
                    $('#serch').show();
                    break;
                case 'searchCust':
                  var inptextTime=$(".demoTable input[name='searchtext']").val();
                    var  inptext=$(".demoTable input[name='searchtext1']").val();
                    var seletext=$("#transSe").find("dl dd.layui-this").attr("lay-value");
                    if(inptextTime!=undefined&&inptextTime!=""){
                        inptext=inptextTime
                    }
           /*         if((inptext == ""&&seletext==undefined)){
                        layer.msg("请输入需要查询的字段与内容");
                    }else if((inptext!=""&&seletext==undefined) ){
                        layer.msg("请输入需要查询的字段");
                    } else  if((seletext!=undefined&&inptext=="")){
                        layer.msg("请输入需要查询内容");
                    }*/
                        var datas={
                            equipId:rowData.equipId,
                            inptext:inptext,
                            column:seletext,
                        }
                        equiTransferReload(datas)

                    break;
            }
        })
        form.on('select(columnName)',function (data) {
            $("#inputValue").show();
            $("#inputValue1").hide();
            if(data.value=="EXE_TIME" || data.value=="EXPIRE_DATE"){
                laydate.render({
                    elem: '#inputValue'
                    , trigger: 'click'
                    , format: 'yyyy-MM-dd'
                });
            }else{
                $("#inputValue").hide();

                $("#inputValue1").show();
            }
        })
        form.on('select(serachInfo)',function (data) {
            $(".demoTable input[name='searchtext']").val("")
            $(".demoTable input[name='searchtext1']").val("")
            if(data.value=="TRANSFER_DATE" || data.value=="APPLICATION_TIME"){
                $("#searchtext").show();
                $("#searchtext1").hide();
                laydate.render({
                    elem: '#searchtext'
                    , trigger: 'click'
                    , format: 'yyyy-MM-dd'
                });
            }else{
                $("#searchtext").hide();
                $("#searchtext1").show();
            }
        })
        //定期事件记录多条件查询
        form.on('submit(event-submit)', function (data) {
            var datas = data.field;
            datas.equipId=rowData.equipId
            if(datas.eventType==''){
                delete datas.eventType
            }
            if($("#columnName").val()=="EQUIP_NAME" ||$("#columnName").val()=="FREQUENCY"){
                datas.inputValue=$("#inputValue1").val();
            }
            if(datas.columnName=="FREQUENCY"){
                if(datas.inputValue.indexOf("两年")!=-1){
                    datas.inputValue="1"
                }
                if(datas.inputValue.indexOf("年")!=-1){
                    datas.inputValue="2"
                }
                if(datas.inputValue.indexOf("月")!=-1){
                    datas.inputValue="3"
                }
                if(datas.inputValue.indexOf("季度")!=-1){
                    datas.inputValue="4"
                }
                if(datas.inputValue.indexOf("周")!=-1){
                    datas.inputValue="5"
                }
                if(datas.inputValue.indexOf("天")!=-1){
                    datas.inputValue="6"
                }
            }
            showEventTable(datas)
        });
        //转移记录多条件查询
        form.on('submit(delect-submit)', function (data) {
            var datas = data.field;
            datas.equipId=rowData.equipId
            if(datas.eventType==''){
                delete datas.eventType
            }
            if($("#serachInfo").val()=="TRANSFER_DATE" ||$("#serachInfo").val()=="APPLICATION_TIME"){
                datas.searchtext=$("#searchtext").val();
            }
        });
        /***设备配件头部按钮操作栏**/
        table.on('toolbar(equipAccessoriesFilter)',function(index){
            var event=index.event;
            switch (event){
                case "add":
                    $.ajax({
                        url: '/EquipmentAccess/EquipAccessItems',
                        data: {equipNo:rowData.equipNo,equipId:rowData.equipId},
                        type: 'get',
                        dataType: 'json',
                        success: function (res) {
                            if(res.obj!=undefined){
                                var index = layer.open({
                                    type: 1,
                                    area: ['600px', '400px'], //宽高
                                    title: '添加',
                                    btn: ['提交', '取消'],
                                    content: '<div class="layui-form" >' +
                                        '<div class="inbox"><label class="layui-form-label"><span class="red">*</span>配件编码</label><div class="layui-input-block">' +
                                        '<input disabled="disabled" lay-verify="required" autocomplete="off"  name="partNo"  class="layui-input"></div></div>' +
                                        '<div class="inbox"><label class="layui-form-label"><span class="red">*</span>配件名称</label><div class="layui-input-block">' +
                                        '<input  name="partName" autocomplete="off"  lay-verify="required"class="layui-input"></div></div>' +
                                        '<div class="inbox"><label class="layui-form-label">型号规格</label><div class="layui-input-block">' +
                                        '<input  name="modelNo" autocomplete="off"  class="layui-input"></div></div>' +
                                        '<div class="inbox"><label class="layui-form-label"><span class="red">*</span>更换周期</label><div class="layui-input-block">' +
                                        '<select name="changeTimes" autocomplete="off" lay-verify="required"><option value="">请选择</option></select></div></div>' +
                                        '<div class="inbox"><label class="layui-form-label"><span class="red">*</span>安装时间</label><div class="layui-input-block">' +
                                        '<input  name="installTime" autocomplete="off" id="installTime" class="layui-input"></div></div>' +
                                        '</div>',
                                    success: function () {
                                        var optionstr="<option value='0'>每两年</option><option value='1'>每天</option><option value='2'>每周</option><option value='3'>每月</option><option value='4'>每季度</option><option value='5'>每半年</option><option value='6'>每年</option>";
                                        $("select[name='changeTimes']").append(optionstr);
                                        laydate.render({
                                            elem: '#installTime'
                                            , trigger: 'click'//呼出事件改成click
                                            , format: 'yyyy-MM-dd'
                                        });
                                        form.render();//初始化表单
                                        $("input[name='partNo']").val(res.obj);
                                    },
                                    yes:function(){
                                        if($("input[name='partName']").val()==""){
                                            layer.msg("请输入配件名称");
                                            return false;
                                        }
                                        if($("select[name='changeTimes']").val()==""){
                                            layer.msg("请选择配件更换周期");
                                            return false;
                                        }
                                        if($("input[name='installTime']").val()==""){
                                            layer.msg("请选择安装时间");
                                            return false;
                                        }
                                        var limsEquipParts={};
                                        limsEquipParts.partName =$("input[name='partName']").val()
                                        limsEquipParts.changeTimes =$("select[name='changeTimes']").val()
                                        limsEquipParts.installTime =$("input[name='installTime']").val()
                                        limsEquipParts.modelNo =$("input[name='modelNo']").val()
                                        limsEquipParts.partNo =$("input[name='partNo']").val()
                                        limsEquipParts.equipId=rowData.equipId;
                                        $.ajax({
                                            url: '/EquipmentAccess/operationEquipAccess',
                                            data: limsEquipParts,
                                            type: 'get',
                                            dataType: 'json',
                                            success: function (res) {
                                                layer.msg(res.msg);
                                                tabRender(tabIndex,rowData);
                                            }
                                        });
                                        layer.closeAll();
                                    }
                                });
                            }else{
                                layer.msg("设备编号生成失败，请核实该设备数据是否填写正确");
                            }
                        }
                    });
                    break;
                case "edit":
                    var  equipData=table.checkStatus('equipAccessories').data;
                    if(equipData==undefined||equipData.length!=1){
                        layer.msg("请选择一条数据进行编辑");
                    }else{
                        var index = layer.open({
                            type: 1,
                            area: ['600px', '400px'], //宽高
                            title: '编辑',
                            btn: ['提交', '取消'],
                            content: '<div class="layui-form"  lay-filter="formpro" >' +
                                '<div class="inbox"><label class="layui-form-label"><span class="red">*</span>配件编码</label><div class="layui-input-block">' +
                                '<input disabled="disabled" autocomplete="off" lay-verify="required"  name="partNo"  class="layui-input"></div></div>' +
                                '<div class="inbox"><label class="layui-form-label"><span class="red">*</span>配件名称</label><div class="layui-input-block">' +
                                '<input  name="partName"  autocomplete="off" lay-verify="required"class="layui-input"></div></div>' +
                                '<div class="inbox"><label class="layui-form-label">型号规格</label><div class="layui-input-block">' +
                                '<input  name="modelNo" autocomplete="off"  class="layui-input"></div></div>' +
                                '<div class="inbox"><label class="layui-form-label"><span class="red">*</span>更换周期</label><div class="layui-input-block">' +
                                '<select name="changeTimes" autocomplete="off" lay-verify="required"><option value="">请选择</option></select></div></div>' +
                                '<div class="inbox"><label class="layui-form-label"><span class="red">*</span>安装时间</label><div class="layui-input-block">' +
                                '<input  name="installTime" autocomplete="off" id="installTime" class="layui-input"></div></div>' +
                                '</div>',
                            success: function () {
                                if(equipData[0].installTime == undefined){
                                    equipData[0].installTime = "";
                                }else{
                                    equipData[0].installTime = format(equipData[0].installTime);
                                }
                                laydate.render({
                                    elem: '#installTime'
                                    , trigger: 'click'//呼出事件改成click
                                    , format: 'yyyy-MM-dd'
                                });
                                form.val("formpro", equipData[0]);
                                var optionstr="<option value='0'>每两年</option><option value='1'>每天</option><option value='2'>每周</option><option value='3'>每月</option><option value='4'>每季度</option><option value='5'>每半年</option><option value='6'>每年</option>";
                                $("select[name='changeTimes']").append(optionstr);
                                $("select[name='changeTimes']").find('option[value="' + equipData[0].changeTimes + '"]').prop('selected', 'ture');
                                form.render();
                            },
                            yes:function(){
                                if($("input[name='partName']").val()==""){
                                    layer.msg("请输入配件名称");
                                    return false;
                                }
                                if($("select[name='changeTimes']").val()==""){
                                    layer.msg("请选择配件更换周期");
                                    return false;
                                }
                                if($("input[name='installTime']").val()==""){
                                    layer.msg("请选择安装时间");
                                    return false;
                                }
                                var limsEquipParts={};
                                limsEquipParts.partName =$("input[name='partName']").val()
                                limsEquipParts.changeTimes =$("select[name='changeTimes']").val()
                                limsEquipParts.installTime =$("input[name='installTime']").val()
                                limsEquipParts.modelNo =$("input[name='modelNo']").val()
                                limsEquipParts.partNo =$("input[name='partNo']").val()
                                limsEquipParts.partId=equipData[0].partId;
                                $.ajax({
                                    url: '/EquipmentAccess/operationEquipAccess',
                                    data: limsEquipParts,
                                    type: 'get',
                                    dataType: 'json',
                                    success: function (res) {
                                        layer.msg(res.msg);
                                        tabRender(tabIndex,rowData);
                                    }
                                });
                                layer.closeAll();
                            }
                        });
                    }
                    break;
                case  "del":
                    var  equipData=table.checkStatus('equipAccessories').data;
                    if(equipData==undefined||equipData.length<=0){
                        layer.msg("请至少选择一条数据");
                    }else{
                        var ids="";
                        for(var i=0;i<equipData.length;i++){
                            ids+=equipData[i].partId+",";
                        }
                        var param={
                            partIds:ids
                        }
                        bottomDelete('/EquipmentAccess/delEquipAccess',param,equipAccessTable,table);
                    }
                    break;
            }
        })
        /***设备附件头部按钮操作栏**/
        table.on('toolbar(equipEnclosureFilter)',function(index){
            var event=index.event;
            switch (event) {
                case "add":
                    var index = layer.open({
                        type: 1,
                        area: ['600px', '300px'], //宽高
                        title: '添加资质文件',
                        btn: ['提交', '取消'],
                        content: '<div class="layui-form" >' +
                            '<div class="inbox"><label class="layui-form-label"><span class="red">*</span>附件名称</label><div class="layui-input-block">' +
                            '<button type="button"  class="layui-btn" id="but_chose" style=" float: right"> <i class="layui-icon">&#xe67c;</i>选择文件 </button>' +
                            '<input disabled="disabled" autocomplete="off" id="attachmentName" name="attachmentName" style="width:300px; float: left"  class="layui-input"></div></div>' +
                            '<div class="inbox"><label class="layui-form-label">文件名称</label><div class="layui-input-block">' +
                            '<input type="text" autocomplete="off" name="fileName" autocomplete="off" class="layui-input"></div></div>' +
                            '<div class="inbox"><label class="layui-form-label">备注</label><div class="layui-input-block">' +
                            '<input type="text" autocomplete="off" name="memo" autocomplete="off" class="layui-input"></div></div>' +
                            '<div class="layui-form-item layui-hide"><input type="button" lay-submit lay-filter="add-file-submit" id="add-file-submit" value="确认"></div>' +
                            '<button hidden id="uploadButton"></button>' +
                            '<input hidden id="attachmentId" name="attachmentId"/>' +
                            '</div>',
                        success: function () {
                            var uploadInst = upload.render({
                                elem: '#but_chose' //绑定元素
                                , url: '../upload?module=' + model//上传接口
                                , accept: 'file'
                                , auto: false
                                , bindAction: '#uploadButton'
                                , multiple: false
                                , choose: function (obj) {
                                    obj.preview(function (index, file, result) {
                                        $('#attachmentName').val(file.name);//显示文件名
                                        $("input[name='fileName']").val(file.name);
                                    });
                                }
                                , done: function (res) {
                                    var obj = res.obj[0];
                                    $('#attachmentId').val(getAttachIds(obj));
                                    $("#add-file-submit").click();
                                    layer.closeAll();
                                }
                            });
                        },
                        yes: function (index, layero) {
                            if ($("#attachmentName").val() == undefined || $("#attachmentName").val() == "") {
                                layer.msg("请选择需要上传的附件");
                                return false;
                            } else {
                                $('#uploadButton').click();
                            }
                        }
                    });
                    form.on('submit(add-file-submit)', function (data) {
                        var limsEquipFile = data.field;
                        limsEquipFile.equipId = rowData.equipId;
                        $.ajax({
                            url: '/EquipmentAccess/operationEquiFile',
                            data: limsEquipFile,
                            type: 'get',
                            dataType: 'json',
                            success: function (res) {
                                layer.msg(res.msg);
                                tabRender(tabIndex, rowData);
                            }
                        });
                    });
                    break;
                case  "del":
                    var equipData = table.checkStatus('equipEnclosure').data;
                    if (equipData == undefined || equipData.length <= 0) {
                        layer.msg("请至少选择一条数据");
                    } else {
                        var ids = "";
                        var attIds = "";
                        for (var i = 0; i < equipData.length; i++) {
                            ids += equipData[i].fileId + ",";
                            attIds += equipData[i].attachmentId + ",";
                        }
                        var data = {
                            attachIds: attIds,
                            type: 1,
                            model: model
                        }
                        $.ajax({
                            type: 'post',
                            url: '/limsFile/delete',
                            data: data,
                            dataType: 'json',
                        });
                        var param = {
                            fileIds: ids
                        }
                        bottomDelete('/EquipmentAccess/delEquiFile', param, equipFileTable, table);
                        break;
                    }
            }
        })
        /***设备附件操作栏**/
        table.on('tool(equipEnclosureFilter)',function(index){
            var event=index.event;
            switch (event){
                case "deatil":
                    if (index.data.attachmentId == undefined || index.data.attachmentId  == "") {
                        layer.msg("文件已被损坏，无法查看");
                    } else {
                        selectFile(index.data.attachmentId, model);
                    }
                    break;
                case "down":
                    window.location.href = "/equipment/limsDownload?model=" + model + "&attachId=" + index.data.attachmentId
                    break;
                case  "del":
                    var data = {
                        attachIds: index.data.attachmentId,
                        type: 1,
                        model: model
                    }
                    $.ajax({
                        type: 'post',
                        url: '/limsFile/delete',
                        data:data,
                        dataType: 'json',
                    });
                    var param={
                        fileIds:index.data.fileId+","
                    }
                    bottomDelete('/EquipmentAccess/delEquiFile',param,equipFileTable,table);
                    break;
            }
        })
        //编辑添加layer
        function editAdd(type,equipId) {
            var title="编辑";
            if(type==0){
                title="新增设备信息";
            }
            var index =  layer.open({
                type: 2,
                skin: 'layui-layer-rim', //加上边框
                area: ['900px', '500px'], //宽高
                title:title,
                maxmin: true,
                btn: ['<div style="background:none;border:none;color:#fff" id="lay-submit">确定</div>', '取消'],
                content: '/equipment/addvice?type='+type+'&id='+equipId+'&name='+escape(name)+'&pid='+pid,
                success:function (res) {
                },
                yes:function (index,layero) {
                    // $(document).find("iframe")[0].contentWindow.getnaStr();
                    var doc = layero.find('iframe')[0].contentDocument;
                    var $btn = $(doc).find("button#submit");
                    $($btn).click();
                    tableObj.reload('Settlement', {
                        url: '/equipment/selectAllEquipment'
                    });
                },
                btn2:function(index,layero){
                    if(type==0){
                        tableObj.reload('Settlement', {
                            url: '/equipment/selectAllEquipment'
                        });
                    }
                },
                cancel:function(index,layero){
                    if(type==0){
                        tableObj.reload('Settlement', {
                            url: '/equipment/selectAllEquipment'
                        });
                    }
                }
            });
        }

        //切换页签渲染底部表格数据  wss
        function tabRender(tabIndex,rowData){
            switch (tabIndex){
                case 0:
                    if(rowData ==undefined){
                        return false;
                    }else{
                        display(rowData)
                    }

                    break
               /* case 1:
                    if(rowData==undefined){
                        $('.layui-collapse').html("");
                    }else{
                        code(rowData.equipId)
                    }
                    break*/
                case 1:
                    if(rowData==undefined){
                        // layui.table.reload("RepairTable",{
                        //    where:{equipId:null}
                        // });
                        repairFunction(null);
                    }else{
                    //RepairLoad(rowData.equipId)   //在方法里面获取全局变量数据
                    laydate.render({
                        elem: '#beginApplicationTime'
                        , trigger: 'click'//呼出事件改成click
                        , format: 'yyyy-MM-dd'
                    });
                    laydate.render({
                        elem: '#endApplicationTime'
                        , trigger: 'click'//呼出事件改成click
                        , format: 'yyyy-MM-dd'
                    });
                    if(RepairTableObject==undefined){
                        repairFunction(rowData.equipId)
                    }else{
                        var param={};
                        param.faultType=""
                        param.faultPosition=""
                        param.applicant=""
                        param.beginTime=""
                        param.endTime=""
                        param.equipId=rowData.equipId
                        RepairLoad(param);//重载维修记录表格
                    }
                    }
                    break
                case 2:
                    if(rowData==undefined){
                        equipBorrowReload(null)
                        // layui.table.reload("lendListTable")
                    }else{
                        var param={
                            "equipId":rowData.equipId
                        }
                        equipBorrowReload(param)
                    }
                    break;
                case  3:
                    if(rowData==undefined){
                        equipuseLogReload(null)
                    }else{
                        var param={
                            "equipId":rowData.equipId
                        }
                        equipuseLogReload(param)
                    }

                    break;
                case 4:
                    if(rowData==undefined){
                        var param={
                            "equipId":0
                        }
                        showEventTable(param)
                    }else{
                        var param={
                            "equipId":rowData.equipId
                        }
                        showEventTable(param)
                    }
                    break;
                case 5:
                    if(rowData==undefined){
                        var param = {
                            "equipId": null
                        }
                        equiTransferReload(param)
                    }else {
                        var param = {
                            "equipId": rowData.equipId
                        }
                        equiTransferReload(param)
                    }
                    break
                case  6:
                    if(rowData==undefined){
                        var param = {
                            "equipId": null
                        }
                        equipAccess(param)
                    }else {
                        var param = {
                            "equipId": rowData.equipId
                        }
                        equipAccess(param)
                    }
                    // var param={
                    //     "equipId":rowData.equipId
                    // }
                    // equipAccess(param);
                    break;
                case 7:
                    if(rowData==undefined){
                        var param = {
                            "equipId": null
                        }
                        equipAFile(param)
                    }else {
                        var param = {
                            "equipId": rowData.equipId
                        }
                        equipAFile(param)
                    }
                    // var param={
                    //     "equipId":rowData.equipId
                    // }
                    // equipAFile(param);
                    break;
            }
        }
        function getTabke(data,stat) {
            tableObj=layui.table.render({
                elem: '#Settlement'
                // ,data:[]
                ,url: '/equipment/selectAllEquipment' //数据接口
                ,where:data
                ,page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                    layout: ['prev', 'page', 'next',  'skip','count','limit',]//自定义分页布局
                    ,limits:[5,10,15,20,25,30,35,40,45,50]
                    ,first: false //不显示首页
                    ,last: false //不显示尾页
                } //开启分页
                ,toolbar:'#toolbar'
                ,cols: [[ //表头
                    {type: 'checkbox' }
                    ,{type: 'numbers', title: '序号'}
                    // ,{field: 'equipId', name:"equipId", title: '设备ID'}
                    ,{field: 'equipNo', title: '资产编号',width:'15%'}
                    ,{field: 'equipName', title: '设备名称',width:'13%', sort: true}
                    ,{field: 'equipStatuasId', title: '状况'}
                    ,{field: 'modelNo', title: '型号'}
                    ,{field: 'spec', title: '规格',hide:true}
                    ,{field: 'deptName', title: '所属部门'}
                    ,{field: 'supplier', title: '供应商',hide:true}
                    ,{field: 'propertyId', title: '产权归属',hide:true}
                    ,{field: 'factoryNo', title: '出厂编号'}
                    ,{field: 'cloudSn', title: '设备序列号'}

                    ,{fixed: 'right',width:140, title: '操作',align:'center', toolbar: '#barOperation'}
                ]]
                ,limit:5
                ,done:function(res) {
                    if(res.data.length!=undefined&&res.data.length>0){
                        rowData=res.data[0]
                        tabRender(tabIndex,rowData)
                    }else{
                        display(res.data[0]);
                    }
                    if(stat==1){
                        $(".demoTable select[name='models']").find('option[value="' +data.column + '"]').prop('selected', 'selected');

                        $(".demoTable input[name='serchtexts']").val(data.inptext);
                        form.render();
                    }
                     $("div[lay-id='Settlement'] .layui-table-body").find("tr").eq(0).click();
                }
            });
        };


    });
    //将毫秒数转为yyyy-MM-dd格式时间
    function format(t) {
        var  str = "";
        var nnow = new Date(t);
        var year = nnow.getFullYear();
        var month = nnow.getMonth()+1;
        var day = nnow.getDate();
        str = year+"-"+month+"-"+day;
        return str;
    }
    //获取当前时间  年月日
    function nowformat() {
        var  nstr = "";
        var now = new Date();
        var nyear = now.getFullYear();
        var nmonth = now.getMonth()+1;
        var nday = now.getDate();
        if(nmonth<10){
            nmonth = "0"+nmonth;
        }
        if(nday<10){
            nday = "0"+nday;
        }
        nstr = nyear+"-"+nmonth+"-"+nday;
        return nstr;
    }
    $("#equip").click(function(){
        window.location.reload()
    })
    $('#fixed').click(function(e){
        e.stopPropagation();
        $('table').width('100%')
        if($(this).attr('dataType')!=1){
            $('.layui-lf').fadeOut();
            $('.layui-rt').animate({width: '100%'});
            $(this).attr('dataType','1');
        }else{
            $('.layui-lf').fadeIn();
            $('.layui-rt').animate({width: '84%'});
            $(this).attr('dataType','0');
        }
    })
    function undefind_nullStr(value) {
        if(value==undefined){
            return ""
        }
        return value
    }
     //点击设备能力节点事件
    $(document).on('click', '.layui-colla-title', function () {
        var typeCode = $(this).attr('typeCode');
        var datas=[];
        for( var i=0;i<resultTypeData.length;i++){
            if(typeCode==resultTypeData[i].typeCode){
                datas.push(resultTypeData[i])
            }
        }
        if ($(this).attr('flag') == 0) {
            var alltbobj={};
            //判断pid是否为0 如果是 就让str等于空，否则就渲染数据
            if(datas.length>0){
                var intabls =  layui.table.render({
                    elem: '#'+typeCode
                    ,data:datas
                    , cols: [[ //表头
                        {field: 'capyName', title: '能力项'}
                        , {field: 'unitNames', title: '单位'}
                        , {field: 'capyInitialValue', title: '出厂能力项'}
                        , {field: 'calibrationValue', title: '检测能力项'}
                        , { width: 220, title: '操作', align: 'center', toolbar: '#barOperation1'}
                    ]]
                });
                alltbobj.name = typeCode;
                alltbobj.tab = intabls;
                alltable.push(alltbobj)
                $(this).attr('flag', '1');
            }
        }

        layui.table.on('tool('+typeCode+'Filter)', function (obj) {
            var layEvent = obj.event;
            var me=$(this);
            if (layEvent === 'edit') { //编辑
                if (me.attr('data-type') == "1") {
                    me.attr('data-type', 0);
                    var tds = obj.tr.find('td');
                    tds.eq(3).data('edit', true)
                    tds.eq(2).data('edit', true)
                    layui.form.render()
                    obj.tr.css("background-color", "rgb(242, 242, 242)");
                    me.text('保存')
                    me.parent("div").append('<a lay-event="cance"  id="cance"style="width:34px;height:22px;line-height:22px;padding-left:5px;" class="layui-btn layui-btn-sm">取消</a>')
                } else {
                    //点击保存
                    obj.tr.find('td').data('edit', false)
                    me.attr('data-type', "1")
                    obj.tr.css("background-color", "white");
                    me.text('编辑')
                    var equipmentCapys=obj.data
                    $.post('/equipmentCapys/editEquipmentCapys',equipmentCapys,function (res) {
                        layui.layer.msg(res.msg, {time:1000,end:function(){
                                reloadtable();
                            }});
                    })
                }
            }else if(layEvent=="cance"){
                obj.tr.find('td').data('edit', false)
                $(this).prev().attr('data-type', "1")
                $(this).prev().text('编辑')
                $(this).remove()
            }
        });
    })
    //        动态表格重载
    function reloadtable() {
        if (alltable == '') return;
        for (var i = 0; i < alltable.length; i++) {
            layui.table.reload(alltable[i].name, alltable[i].tab);
        }
    }
    function code(data) {
        $.get('/equipmentCapys/selectByEquipId', {equipId: data}, function (res) {
            resultTypeDatass = res.data[0];
            resultTypeDatas=resultTypeData = res.data[1];
            var str = "";
            if(resultTypeDatass!=undefined){
                for (var i = 0; i < resultTypeDatass.length; i++) {
                    str += '<div class="layui-colla-item" style="position: relative">' +
                        '<h2  class="layui-colla-title" style="height: 36px;line-height:36px" typeCode="' + resultTypeDatass[i].typeCode + '" flag="0">' + resultTypeDatass[i].typeName + '</h2>' +
                        '<div class="layui-colla-content" style="padding:0 1px;">' +
                        '<div class="layui-card-body">' +
                        '<table id="' + resultTypeDatass[i].typeCode + '" lay-filter="' + resultTypeDatass[i].typeCode + 'Filter"></table>' +
                        '</div>' +
                        '</div>' +
                        '</div>'
                }
            }
            $('.layui-collapse').html(str);
            layui.element.render();
        })
    }
</script>
<script>
    function doRemoveBatch(){
        var data=layui.table.checkStatus('Settlement').data;
        if(data.length<0||data.length==0){
            layer.msg("请至少选择一条记录！");
            return false;
        }
        var equipIds ='';
        for (var i=0;i<data.length;i++){
            equipIds+=data[i].equipId+",";
        }
        layer.confirm('确认要删除吗？',{
            btn: ['确认','取消'],
            icon:7,
            title:"系统提示"
        }, function(){
            $.ajax({
                url: "/equipment/deleteArrayEquipment",
                type: "post",
                data: {"equipIds":equipIds},
                dataType: "json",
                traditional: true,
                success: function(res){
                    layui.layer.msg(res.msg, {time:2000,end:function(){
                            location.reload() ;
                        }});

                }
            });
        }, function(){
            layer.closeAll();
        });
    }
    function display(data){
        if(data==undefined || data=='undefined'){
            $('.none').html('');
            $(".total").addClass("active");
        }else{
            if(directjudge==pid){
                $('.hide').show();
                if( $('.hide').attr('dataType')==1){
                    if(data.directionId=='三向'){
                        $('.hideY').css('visibility','visible')
                    }else{
                        $('.hideY').css('visibility','hidden')
                    }
                    $('.chooseBot').find('td').eq(0).before($('.chooseTop').find('td').eq(5))
                    $('.chooseBot').find('td').eq(0).before($('.chooseTop').find('td').eq(4));
                    $('.hide').attr('dataType',0)
                }else{
                    if(data.directionId=='三向'){
                        $('.hideY').css('visibility','visible')
                    }else{
                        $('.hideY').css('visibility','hidden')
                    }
                }
            }else{
                $('.hide').hide();
                if($('.hide').attr('dataType')!=1) {
                    $('.chooseTop').find('td').eq(3).after($('.chooseBot').find('td').eq(0))
                    $('.chooseTop').find('td').eq(4).after($('.chooseBot').find('td').eq(1))
                    $('.hide').attr('dataType', 1)
                }
            }
            $('#equipNo').html(data.equipNo);
            $('#equipName').html(data.equipName);
            $('#equipStatuasId').html(data.equipStatuasId);
            $('#equipTypeName').html((data.equipTypeName));
            $('#modelNo').html(data.modelNo);
            $('#spec').html(data.spec);
            $('#manufacturer').html(data.manufacturer);
            $('#supplier').html(data.supplier);
            $('#positionName').html(data.positionName);
            $('#factoryNo').html(data.factoryNo);
            $('#propertyNo').html(data.propertyNo);
            $('#dateProduc').html(format(data.dateProduc));
            $('#recordDate').html(format(data.recordDate));
            $('#sourceAssets').html(data.sourceAssets);
            $('#assetsCost').html(data.assetsCost);
            $('#propertyId').html(data.propertyId);
            $('#accountFile').html(data.accountFile);
            $('#sensitivityX').html(data.sensitivityX);
            $('#sensitivityY').html(data.sensitivityY);
            $('#sensitivityZ').html(data.sensitivityZ);
            $('#phyQuantiId').html(data.phyQuantiId);
            $('#directionId').html(data.directionId);
            $('#couplingId').html(data.couplingId);
            $('#cloudSn').html(data.cloudSn);
            $('#custodian').html(data.custodian);
            $('#standMateYn').html(data.standMateYn);
            $('#technicalParm').html(data.technicalParm);
            $('#memo').html(data.memo);
            $('#deptId').html(data.deptId);
            $('#deptName').html(data.deptName);
            $(".total").removeClass("active");
        }
    }
    //公共删除方法（删除最后一项自动跳转前一页）
    function publicDelete(url,equipId,tableObj,table){
        layer.confirm('确定要删除吗?', {icon: 3, title:'提示'}, function(index){
            var data={
                equipId:equipId
            }
            var res=toAjax(url,data);
            layer.msg(res.msg)
            if(res.code==0){
                try {
                    if (equipId.substring(equipId.length - 1) == ",") {
                        equipId = equipId.substring(0, equipId.length - 1);
                    }
                    var dataSize = equipId.split(",");
                    var dataAll = table.cache[tableObj.config.id];
                    if (dataAll.length == dataSize.length) {
                        //得到当前页
                        var page = $(".layui-laypage-skip .layui-input").val();

                        if (page > 1) {
                            tableObj.reload({
                                page: {
                                    curr: page - 1 //重新从第 1 页开始
                                }}
                            );
                        }else{
                            tableObj=tableObj.reload();
                        }
                    } else {
                        tableObj=tableObj.reload();
                    }
                } catch (e) {
                    tableObj.reload();
                }
            }
            layer.close(index);
        });
    }
    function toAjax(url,data) {
        var result;
        $.ajax({
            url:"/equipment/deleteEquipment",
            data:data,
            type: 'post',
            async:false,
            dataType: 'json',
            success: function (res){
                result=res;
            }
        });
        return result;
    }
    //子调父关闭弹框方法
    function close() {
        layer.closeAll();
    }
    //维修记录表格初始化函数
    function repairFunction(equipId){
     /*   if(equipId==''||equipId==undefined){
            $("#repairData").show();
        }else{*/
            $("#repairData").hide();
            //渲染设备维修记录下现象分类下拉框 ajax
            $.ajax({
                url: '/equipment/selectAllCommonCode?parentTyepNo=EQUIP_FAILURE'
                , type: 'post'
                , success: function (res) {
                    var fault = ''
                    for (var i = 0; i < res.data.length; i++) {
                        fault += '<option value="' + res.data[i].codeNo + '">' +  res.data[i].codeName + '</option>'
                    }
                    $('#faultType').append(fault)
                    layui.form.render('select');
                }
            })
            RepairTableObject=layui.table.render({
                elem: '#RepairTable'
                ,page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                    limits:[5,10,15,20,25,30,35,40,45,50]
                } //开启分页
                ,url:"/equipment/selectByequipId"
                ,where:{
                    equipId:equipId
                }
                ,limit:5
                ,cols:[[ //表头
                    {field: 'repalogId', title: '记录编号'}
                    ,{field: 'equipName', title: '设备名称'}
                    ,{field: 'equipStatuasCode', title: '维修状态',templet:function(d){
                            if(d.repairStatus=="1"){
                                return '报修中'
                            }else if(d.repairStatus=="2"){
                                return '维修中'
                            }else if(d.repairStatus=="3"){
                                return '验证中'
                            }else if(d.repairStatus=="0"){
                                return '已完成'
                            }
                        }}
                    ,{field: 'faultType', title: '现象分类'}
                    ,{field: 'faultPosition', title: '发生部位'}
                    ,{field: 'faultDesc', title: '故障描述'}
                    ,{field: 'applicant', title: '报修人'}
                    ,{field: 'applicationTime', title: '报修时间'}
                    ,{title: '操作',align:'center', toolbar: "#repairToolbar"}
                ]]
                ,done: function (res) {
                }
            })
        }
  /*  }*/
    //维修表格重新加载函数
    function RepairLoad(param) {//设备id，参数
        if(param.faultType==undefined){
            param.faultType=''
        }
        if(param.faultPosition==undefined){
            param.faultPosition=''
        }
        if(param.applicant==undefined){
            param.applicant=''
        }
        if(param.beginTime==undefined){
            param.beginTime=''
        }
        if(param.endTime==undefined){
            param.endTime=''
        }
        RepairTableObject.reload({
            url:'/equipment/selectByequipId',
            page:true,
            method:'post',
            where:{
                equipId:rowData.equipId,
                faultType:param.faultType,
                faultPosition:param.faultPosition,
                applicant:param.applicant,
                beginTime:param.beginTime,
                endTime:param.endTime,
            }
        })
    }
    //设备借还记录表格渲染
    function equipBorrowReload(data) {
        layui.table.render({
            elem: '#lendListTable'
            , url: '/EquipBorrow/equipBorrowData'
            , page: true //开启分页
            , where: data
            , cols: [[ //表头
                {
                    field: 'approverStatus', title: '审批状态', templet: function (d) {
                        if (d.approverStatus == 2) {
                            return '已准'
                        }
                        if(d.approverStatus==3){
                            return '未准'
                        }
                        if(d.approverStatus==1){
                            return '待批'
                        }
                        if(d.approverStatus==0){
                            return '新建'
                        }
                    }
                }
                , {
                    field: 'borrowTime', title: '借用时间', templet: function (d) {
                        if (d.borrowTime == undefined) {
                            return '';
                        }
                        d.borrowTime = new Date(d.borrowTime).Format("yyyy-MM-dd");
                        return d.borrowTime;
                    }
                }
                , {field: 'borrowerdeptName', title: '借用部门'}
                , {field: 'borrowerUser', title: '借用人'}
                , {
                    field: 'expectReturnDate', title: '预计归还日期', templet: function (d) {
                        if (d.expectReturnDate == undefined) {
                            return '';
                        }
                        d.expectReturnDate = new Date(d.expectReturnDate).Format("yyyy-MM-dd");
                        return d.expectReturnDate;
                    }
                }
                , {
                    field: 'returnStatus', title: '归还状态', templet: function (d) {
                        if (d.returnStatus == 0) {
                            return '未归还'
                        } else {
                            return '已归还'
                        }
                    }
                }
            ]]
            , limit: 5 //每页默认显示的数量
            , limits: [5, 10, 15, 20, 25, 30]
        });
    }
    //设备使用记录表格渲染
    function equipuseLogReload(data){
        layui.table.render({
            elem: '#useLogTable'
            , url: '/EquipBorrow/equipUseLogData'
            , page: true //开启分页
            , where: data
            , cols: [[ //表头
                {field: 'PROPERTY_NO', title: '资产名称'}
                , {field: 'BORROW_USER', title: '借用人'}
                , {field: 'PROJECT_NO', title: '立项编号'}
                , {field: 'PROJECT_NAME', title: '项目名称'}
                , {field: 'BORROW_TIME', title: '开始使用时间',templet:function(d){
                        if (d.BORROW_TIME == undefined) {
                            return '';
                        }
                        d.BORROW_TIME = new Date(d.BORROW_TIME).Format("yyyy-MM-dd");
                        return d.BORROW_TIME;
                    }}
                , {field: 'RETURN_TIME', title: '结束使用时间',templet:function(d){
                        if (d.RETURN_TIME == undefined) {
                            return '';
                        }
                        d.RETURN_TIME = new Date(d.RETURN_TIME).Format("yyyy-MM-dd");
                        return d.RETURN_TIME;
                    }}
                , {field: 'CLOUD_SN', title: '云端SN号'}
                , {field: 'MEMO', title: '备注'}
            ]]
            , limit: 5 //每页默认显示的数量
            , limits: [5, 10, 15, 20, 25, 30]
        });
    }
    //设备定期事件执行记录表格
    function showEventTable(data){
        layui.table.render({
            elem: '#eventTable'
            , url: '/LimsEquipEventlog/showAll'
            , page: true //开启分页
            , where: data
            ,cols: [[ //表头
                {type: 'checkbox' }
                ,{field: 'eventLogId', title: '记录编号'}
                ,{field: 'equipName', title: '设备名称'}
                ,{field: 'equipEventType', title: '事件类型',templet : function(data){
                        if(data.equipEventType=="EQUIP_EVENT_TYPE1"){
                            return "检定校准"
                        }else if(data.equipEventType=="EQUIP_EVENT_TYPE2"){
                            return "期间核查"
                        }
                    }
                }
                ,{field: 'frequency', title: '维护频率',templet : function(data){
                        if(data.frequency=='1'){
                            return '每两年'
                        }else if(data.frequency=='2'){
                            return '每年'
                        }else if(data.frequency=='3'){
                            return '每月'
                        }else if(data.frequency=='4'){
                            return '每季度'
                        }else if(data.frequency=='5'){
                            return '每周'
                        }else if(data.frequency=='6'){
                            return '每天'
                        }else{
                            return "";
                        }
                    }}
                ,{field: 'exeTime', title: '上次执行日期'}
                ,{field: 'expireDate', title: '下次到期日期'}
                ,{field: 'workflowNo', title: '流水号'}
            ]]
            ,limit:5
            , limits: [5, 10, 15, 20, 25, 30]
        });
    }
    //设备转移记录表格渲染
    function equiTransferReload(data){
        if(data.column!=undefined){
            if(data.column=="APPROVAL_STATUS"){
                if(data.inptext=="新建"){
                    data.inptext="0"
                }
                else if(data.inptext=="待批"){
                    data.inptext="1"
                }else if(data.inptext=="已批"){
                    data.inptext="2"
                }else if(data.inptext=="未批"){
                    data.inptext="3"
                }
            }
            if(data.column=="list.RECEIVE_STATUS"){
                if(data.inptext=="未接收"){
                    data.inptext="0"
                } else if(data.inptext=="全部接收"){
                    data.inptext="2"
                }
                else if(data.inptext=="部分接收"){
                    data.inptext="1"
                }
            }
        }
        layui.table.render({
            elem: '#transferTable'
            , url: '/equipTransfer/transferData'
            , page: true //开启分页
            ,toolbar:"#approval"
            , where: data
            , cols: [[ //表头
                {field: 'transferDate', title: '调拨日期'}
                , {field: 'originalDeptId', title: '原部门'}
                // , {field: 'originalCustodian', title: '原保管人'}
                , {field: 'newDeptId', title: '新部门'}
                // , {field: 'newCustodianName', title: '新保管人'}
                , {field: 'application', title: '申请人'}
                , {field: 'applicationTime', title: '申请时间', templet: function (d) {
                        if (d.applicationTime == undefined) {
                            return '';
                        }
                        d.applicationTime = new Date(d.applicationTime).Format("yyyy-MM-dd");
                        return d.applicationTime;
                    }}
                , { field: 'approvalStatus', title: '审批状态', templet: function (d) {
                        if (d.approvalStatus == "2") {
                            return '已准'
                        }
                        if(d.approvalStatus=="3"){
                            return '未准'
                        }
                        if(d.approvalStatus=="1"){
                            return '待批'
                        }
                        if(d.approvalStatus=="0"){
                            return '新建'
                        }

                    }} , { field: 'receiveStatus', title: '接收状态', templet: function (d) {

                        if(d.receiveStatus=="1"){
                            return '已接收'
                        }
                        if(d.receiveStatus=="0"){
                            return '未接收'
                        }
                    }}
            ]]
            , limit: 5 //每页默认显示的数量
            , limits: [5, 10, 15, 20, 25, 30]
            ,done:function(){
                if(data.column=="TRANSFER_DATE"||data.column=="APPLICATION_TIME"){
                    $("#searchtext").val(data.inptext);  //日期输入框
                    $("#searchtext").show();
                    dateKj.render({
                        elem: '#searchtext'
                        , trigger: 'click'
                        , format: 'yyyy-MM-dd'
                    });
                    $("#searchtext1").hide();
                }else{
                    $("#searchtext1").val(data.inptext);  //输入框
                    $("#searchtext").hide();
                    $("#searchtext1").show();
                }
                $('#serachInfo').val(data.column);
                layui.form.render('select');
            }
        });
    }
    //设备配件表格渲染
    function equipAccess(data){
        equipAccessTable=layui.table.render({
            elem: '#equipAccessories'
            , url: '/EquipmentAccess/getEquipAccess'
            , page: true
            ,toolbar:"#equipAccessHeadBtn"
            , where: data
            , cols: [[ //表头
                {type: 'checkbox'},
                {field: 'partNo', title: '配件编号'}
                , {field: 'partName', title: '配件名称'}
                , {field: 'modelNo', title: '型号规格'}
                , {field: 'changeTimes', title: '更换周期',templet:function(d){
                        if(d.changeTimes==0){
                            return "每两年";
                        }
                        if(d.changeTimes==1){
                            return "每天";
                        }
                        if(d.changeTimes==2){
                            return "每周";
                        }
                        if(d.changeTimes==3){
                            return "每月";
                        }
                        if(d.changeTimes==4){
                            return "每季度";
                        }
                        if(d.changeTimes==5){
                            return "每半年";
                        }
                        if(d.changeTimes==6){
                            return "每年";
                        }
                    }}
                , {field: 'installTime', title: '安装时间',templet: function (d) {
                        if (d.installTime == undefined || d.installTime == "") {
                            return d.installTime == "";
                        } else {
                            d.installTime = new Date(d.installTime).Format("yyyy-MM-dd");
                            return d.installTime;
                        }
                    }}
                , {field: 'nextInstallTime', title: '下次更换时间',templet: function (d) {
                        if (d.nextInstallTime == undefined || d.nextInstallTime == "") {
                            return d.nextInstallTime == "";
                        } else {
                            d.nextInstallTime = new Date(d.nextInstallTime).Format("yyyy-MM-dd");
                            return d.nextInstallTime;
                        }
                    }}
            ]]
            , limit: 5
        });
    }
    //设备附件表格渲染
    function equipAFile(data){
        equipFileTable=layui.table.render({
            elem: '#equipEnclosure'
            , url: '/EquipmentAccess/getEquipFile'
            , page: true
            ,toolbar:"#equipFileHeadBtn"
            , where: data
            , cols: [[ //表头
                {type: 'checkbox'},
                {field: 'fileName', title: '附件名称'}
                , {field: 'updateTime', title: '上传时间',templet: function (d) {
                        if (d.updateTime == undefined || d.updateTime == "") {
                            return d.updateTime == "";
                        } else {
                            d.updateTime = new Date(d.updateTime).Format("yyyy-MM-dd");
                            return d.updateTime;
                        }
                    }}
                , {field: 'updateNmae', title: '上传人'}
                , {field: 'memo', title: '备注'}
                , {width: 200, title: '操作', align: 'center', toolbar: '#equipoperation'}
            ]]
            , limit: 5
        });
    }
    //底部页签数据删除跳转前一页数据
    function bottomDelete(url,data,tableIns,table){
        layer.confirm('确定要删除吗?', {icon: 3, title:'提示'}, function(index){
            $.ajax({
                url:url,
                data:data,
                type: 'get',
                dataType: 'json',
                success: function (res){
                    layer.msg(res.msg)
                    if(res.code==0){
                        var ids="";
                        if(data.partIds!=undefined){
                            ids=data.partIds
                        }
                        if(data.fileId!=undefined){
                            ids=data.fileId
                        }
                        var page= $(".layui-laypage-skip").eq(1).find(".layui-input").val();
                        try {
                            if (ids.substring(ids.length - 1) == ",") {
                                ids = ids.substring(0, ids.length - 1);
                            }
                            var dataSize = ids.split(",");
                            var dataAll = table.cache[tableIns.config.id];
                            if (dataAll.length == dataSize.length) {
                                if (page > 1) {
                                    tableIns.reload({
                                            page: {
                                                curr: page - 1 //重新从第 1 页开始
                                            }
                                        }
                                    );
                                } else {
                                    tableIns = tableIns.reload();
                                }
                            } else {
                                tableIns = tableIns.reload();
                            }
                        } catch (e) {
                            tableIns.reload();
                        }
                    }
                    layer.close(index);
                }
            });
        });
    }
</script>
</body>
</html>